//导入axios
import axios from "axios";

//创建服务
const Server = axios.create({
    baseURL: "https://api-hmugo-web.itheima.net/api/public/v1",
    timeout: 5000,
});

//前置拦截器，请求发送出去之前触发
Server.interceptors.request.use((config) => {
    console.log("前置拦截器触发");
    // config.headers['Authorization'] = 123;

    return config;

}, error => Promise.reject(error));


//后置拦截器,请求响应回来之后触发
Server.interceptors.response.use((response) => {
    console.log("后置拦截器触发");

    return response.data;
}, error => Promise.reject(error));

export default Server;